import { Controller, Get, Put, Body, Delete, Param, Post } from "@nestjs/common";
import { ApiTags, ApiOperation } from "@nestjs/swagger";

import {TagService} from './tag.service'
import {TagDto} from './tag.dto'

@Controller('tag')
@ApiTags('标签')
export class TagController{
    constructor(
        private readonly tagService:TagService
    ){}
    @Get()
    @ApiOperation({ summary: '查询所有博客标签' })
    async find(){
        return await this.tagService.find();
    }

    @Put()
    @ApiOperation({ summary: '增加博客标签' })
    async add(@Body() tag:TagDto){
        return await this.tagService.add(tag);
    }

    @Delete(':id')
    @ApiOperation({ summary: '根据id删除标签' })
    async remove(@Param('id') tagId){
        return await this.tagService.remove(tagId);
    }

    @Post()
    @ApiOperation({summary:'根据id修改标签'})
    async update(@Body() tag:TagDto){
        return await this.tagService.update(tag)
    }
}